package IC;
import java.io.*;

import IC.Parser.*;
import java_cup.runtime.Symbol;


/*Main Class*/
public class Compiler
{
	public static void main(String[] args) throws IOException, LexicalError
	{

		if (args.length != 1){
			System.out.println("The number of parameters is wrong");
			return;
		}   	

		FileReader inputFile = new FileReader(args[0]);
		Token currToken;
	
		    try {
		    	// Create a new scanner
		    	Lexer scanner = new Lexer(inputFile);
		    	//loop
		    	do {
					try
					{
						currToken = scanner.next_token();
					}
					catch(LexicalError e)
					{
						System.out.println(e.getMessage());
						return;
					}
					if ((currToken.getId()==sym.ID) || (currToken.getId()==sym.CLASS_ID) || (currToken.getId()==sym.QUOTE)  ||(currToken.getId()==sym.INTEGER)  )
					System.out.println(currToken.getLine() + ": " + currToken.toStr(currToken.getId()) + "(" + currToken.getValue() + ")");
					else 
						System.out.println(currToken.getLine() + ": " + currToken.toStr(currToken.getId()));
				} while (currToken.sym != sym.EOF);
		    	
		    } catch (IOException ex) {
		    	System.out.println("unexpected problem with input file");
		    }
	} 
}

